package leetcode.动态规划.simple;

/**
 * @author wangmaolin1
 * @date 2022/1/10 下午9:47
 */
public class _392判断子序列 {

    public boolean isSubsequence(String s, String t) {
        if (s.length() == 0 && t.length() == 0) {
            return true;
        }
        if (s.length() == 0) {
            return false;
        }

        char[] charsS = s.toCharArray();
        char[] charsT = t.toCharArray();
        int si = 0;
        for (char c : charsT) {
            if (c == charsS[si]) {
                if (si == charsS.length - 1) {
                    return true;
                }
                si++;
            }
        }
        return false;
    }


}
